// Fill out your copyright notice in the Description page of Project Settings.

#include "Isalong2.h"
#include "UIManager.h"
#include "DBuildingHurtLogic.h"




UDBuildingHurtLogic::UDBuildingHurtLogic()
{
	_override_OnHurt = true;
}

void UDBuildingHurtLogic::OnHurt(AActor* shotter, FVector impactNormal, FVector hitLocation, int HurtType, float hurtValue, UPrimitiveComponent* hitComponent)
{
	switch (HurtType)
	{
	case 11:
		_compOwner->GetDMesh()->ApplyRadiusDamage(1.2, hitLocation, 15, 4000, false);
		_compOwner->SetBuildingLife(_compOwner->GetBuildingLife() - 0.5*hurtValue);
		break;
	default:
		_compOwner->GetDMesh()->ApplyRadiusDamage(0.7, hitLocation, 5, 500, false);
		_compOwner->SetBuildingLife(_compOwner->GetBuildingLife() - 0.2);
		break;
	}
	// test code

	AUIManager::_UIManager->AddDisplayBlood(_compOwner, true, 3, _compOwner->GetBuildingLife());


	if (_compOwner->GetBuildingLife() <= 0)
	{
		_compOwner->ToolKillSelf();
	}
}
